//
//  BC_Hashvalue.m
//  CocOth
//
//  Created by BrunoCausse on 11/03/11.
//  Copyright 2011 poulailler cie. All rights reserved.
//

#import "BC_Hashvalue.h"


@implementation BC_Hashvalue

@synthesize depth, selectivity, move;
@synthesize lower, upper;

- (id)initWithPacked:(unsigned long long)packed
{
    self = [super init];
    if (self) {
        // Initialization code here.
        lower = (short)(packed & 0x000000000000FFFFULL);
        packed >>= 16;
        upper = (short)(packed & 0x000000000000FFFFULL);
        packed >>= 16;
        move = (unsigned char)(packed & 0x00000000000000FFULL);
        packed >>= 8;	
        selectivity = (unsigned char)(packed & 0x00000000000000FFULL);
        packed >>= 8;	
        depth = (unsigned char)(packed & 0x00000000000000FFULL);
        packed >>= 8;	
        reserve = (unsigned char)(packed & 0x00000000000000FFULL);
        
    }
    
    return self;
}

- (void)dealloc
{
    [super dealloc];
}


- (unsigned long long)wide_2_compact
{
    unsigned long long packed = reserve;
	packed <<= 8;
	packed 	|= depth;
	packed <<= 8;
	packed 	|= selectivity;
	packed <<= 8;
	packed 	|= move;
	packed <<= 16;
	packed 	|= ((long long)upper & 0x000000000000FFFFULL);
	packed <<= 16;
	packed 	|= ((long long)lower & 0x000000000000FFFFULL);
	
	return packed;

}
- (void)compact_2_wide:(unsigned long long)packed
{
    lower = (short)(packed & 0x000000000000FFFFULL);
	packed >>= 16;
	upper = (short)(packed & 0x000000000000FFFFULL);
	packed >>= 16;
	move = (unsigned char)(packed & 0x00000000000000FFULL);
	packed >>= 8;	
	selectivity = (unsigned char)(packed & 0x00000000000000FFULL);
	packed >>= 8;	
	depth = (unsigned char)(packed & 0x00000000000000FFULL);
	packed >>= 8;	
	reserve = (unsigned char)(packed & 0x00000000000000FFULL);


}


@end
